<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ShopCart extends Model
{
    protected $table = 'shop_carts';

    protected $fillable = [
        'user_id',
        'goods_id',
        'quantity'
    ];

    // 定义与 User 模型的关联
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    // 定义与 Good 模型的关联
    public function goods()
    {
        return $this->belongsTo(Good::class, 'goods_id', 'id');
    }
}
